package rsj.proxy.register;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import rsj.annotation.MyScanner;

import java.util.Map;

/**
 * 扫描路径下的接口、将接口代理对象注册到spring容器
 *
 * @author yuanqinglong
 * @since 2021/4/2 15:48
 */
public class MapperRegister implements ImportBeanDefinitionRegistrar {


    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(MyScanner.class.getName());
        String[] basePackages = (String[]) annotationAttributes.get("basePackages");
        ClassPathMapperScan classPathMapperScan = new ClassPathMapperScan(registry);
        classPathMapperScan.doScan(basePackages);
    }

}
